<!DOCTYPE html>
<html>
<head>
	<title>创建XMLHttpRequest对象</title>
</head>
<body>
	<script type="text/javascript">
		function createXMLHttpRequest(){
			var request =false;
			if(window.XMLHttpRequest){
				request = new XMLHttpRequest();
				if(request.overrideMinmeType){
					request.overrideMinmeType('text/xml');
				}
			}
			return request;
		}

		window.onload=function(){
			var btn = document.getElementById("btn");
			btn.onclick = function(){
				var ajax = createXMLHttpRequest();
				console.log(ajax);
			}
		}

	</script>

	<input type="button" id="btn" value="请求服务器">
</body>
</html>